<?php
require_once '../vendor/autoload.php';   
use PhpAmqpLib\Connection\AMQPStreamConnection;

$connection = new AMQPStreamConnection('106.13.63.203',5672, '1703phpa', '123456','1703phpa');
$channel = $connection->channel();

$channel->queue_declare('task_queue', false, true, false, false);

echo " [*] Waiting for messages. To exit press CTRL+C\n";

$callback = function ($msg) {
    echo ' Consumer1 Received ', $msg->body, "\n";
    sleep(2);
    echo " consumer1 Done\n";
    $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
};

$channel->basic_qos(null, 1, null);
$channel->basic_consume('task_queue', '', false, false, false, false, $callback);

while (count($channel->callbacks)) {
    $channel->wait();
}

$channel->close();
$connection->close();
?>
